<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="UTF-8">
<title>带关闭按钮的滚动广告</title>
<style type="text/css">
#main{ text-align:center;}
#float{
	position:absolute;
	left:30px;
	top:60px; 
	z-index:1;
	}
#close{
	position:absolute;
	top:60px;
	left:134px;
	z-index:2;
	cursor:hand;
}

</style>
	<script type="text/javascript">
		var wei;
		var weitop;
		var weileft;
		var wei1;
		var weitop1;
		var weileft1;
		function inx(){
			 wei=document.getElementById("close")
			 wei1=document.getElementById("float");
			 if(wei.currentStyle){
			 weitop=parseInt(wei.currentStyle.top);
			 weileft=parseInt(wei.currentStyle.left);
			 weitop1=parseInt(wei1.currentStyle.top);
			 weileft1=parseInt(wei1.currentStyle.left);
			 }
			 else{
			 	weitop=parseInt(document.defaultView.getComputedStyle(wei,null).top);
			 	weileft=parseInt(document.defaultView.getComputedStyle(wei,null).left);
			 	weitop1=parseInt(document.defaultView.getComputedStyle(wei1,null).top);
			 	weileft1=parseInt(document.defaultView.getComputedStyle(wei1,null).left);
			 
			 }
		}
		function move(){
			var mtop=parseInt(document.documentElement.scrollTop||document.body.scrollTop);
			var mleft=parseInt(document.documentElement.scrollLeft||document.body.scrollLeft); 
			wei.style.top=weitop+mtop+"px";
			wei.style.left=weileft+mleft+"px";
			wei1.style.top=weitop1+mtop+"px";
			wei1.style.left=weileft1+mleft+"px";
		}
		function adv_close(){
			document.getElementById("close").style.display="none";
			document.getElementById("float").style.display="none";
		}
		window.onload=inx;
		window.onscroll=move;
	</script>
</head>
<body>
<div id="close" onClick="adv_close()"><img src="images/close.jpg"></div>
<div id="float"><img src="images/advpic.jpg"></div>
<div id="main"><img src="images/contentpic.jpg"></div>
</body>
</html>
